package top.jacktgq.itheima.netty.protocol_design.groupchat.protocol.serializer;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @Author CandyWall
 * @Date 2021/3/25--10:43
 * @Description
 */
public class Config {
    static Properties props;

    static {
        try (InputStream in = Config.class.getResourceAsStream("/application.properties")) {
            props = new Properties();
            props.load(in);
        } catch (IOException e) {
        }
    }

    public static Serializer.Algorithm getSerializerAlgorithm() {
        String value = props.getProperty("serializer.algorithm");
        if (value == null) {
            return Serializer.Algorithm.Java;
        } else {
            return Serializer.Algorithm.valueOf(value);
        }
    }
}
